<style>
<!--
td.inforvbar:hover{
	background-image:url('<?php echo $this->webroot;?>img/lam/button-background.png') ;
	background-color: #82AAE2;
	background-repeat:repeat-x;
	font-weight: bold;
}
-->
</style>
<div class="posts index">
	<div class="hdr-bg"> 
		<div class="header-message">CÁC TIN RAO</div> 
		<div style="display: block; background-color: #6BA4E6; height: 3px; overflow: hidden;"></div>
	</div> 
	<div class="hdr-bg"> 
		<div class="choose-type"> 
			<div class="select">
			<?php echo $form->create('Post');?>
					<span class="select-type">
						Chọn loại: <?php echo $form->input('type_id', array('style' => 'vertical-align: text-top', 'id' => 'ty_id', 'class' => false, 'div' => false, 'label' => false, 'onchange' => 'filter();'));?>
					</span>
					<span class="select-type">
						Chọn danh mục: <?php echo $form->input('category_id', array('style' => 'vertical-align: text-top', 'id' => 'ca_id', 'class' => false, 'div' => false, 'label' => false, 'onchange' => 'filter();'));?>
					</span>
					<span class="select-type">
						Chọn khu vực: <?php echo $form->input('city_id', array('style' => 'vertical-align: text-top', 'id' => 'ci_id', 'class' => false, 'div' => false, 'label' => false, 'onchange' => 'filter();'));?>
					</span>
			</div>
			<?php echo $form->end();?>
		</div> 
	</div> 
											
	<!-- Tin rao moi nhat --> 
											
	<table border="0" cellpadding="5" cellspacing="0" width="100%" class="add"> 
		<tbody>
			<tr>
				<td class="section_subtitle" style="text-align: center;">Loại</td>
				<td class="section_subtitle">Tin rao</td>
				<td class="section_subtitle">Lượt xem</td>			
				<td class="section_subtitle">Ngày đăng</td>
				<td class="section_subtitle">Nơi đăng</td>
			</tr>		
			<?php
			$i = 0;
			foreach ($posts as $post):
				$class = null;
				if ($i++ % 2 == 0) {
				$class = 'bgcolor="#f6fbff" height="20"';
			}
			?>
			<tr <?php echo $class ; ?> class="test"> 
				<td class="inforvbar" align="center" width="80">
					<a href="<?php echo $this->webroot;?>posts/index/<?php echo$post['Type']['id'];?>/0/0">
						<div class="imgborder"><img src="<?php echo $this->webroot; ?>img/post/types/<?php echo $post['Type']['image'];?>" border="0" height="14" width="14"></div>
					</a>
				</td>
						
				<td class="inforvbar" style="padding-left: 5px; vertical-align: top;"> 
					
					<span style="padding-left : 3px ; padding-right : 3px "><?php echo $html->link($post['Post']['title'], array('controller' => 'posts', 'action' => 'view', $post['Post']['id']), array('id' => 'rvtitle')) ; ?></span>
					<font style="font-weight: normal; color: rgb(0, 128, 0);"> (<?php echo count($post['Comment']) ; ?>) </font> 
					<span style="position: absolute; margin-top: 2px;"></span><br> 
				</td> 

				<td class="inforvbar" align="center" width="80">
					<?php echo $post['Post']['count']; ?>
				</td>
				 				
				<td class="inforvbar" align="center" width="80">
					<?php echo date( "d/m/Y" , strtotime($post['Post']['created'])); ?>
				</td>
				
				<td class="inforvbar" align="center" width="80">
					<?php echo $post['City']['name']; ?>
				</td>
			</tr>  
			<?php endforeach; ?>										
		</tbody>
	</table> 
	
	

	<div class="paging" style="text-align: right;">
		<?php echo $this->Paginator->prev('<< ' . __('Lui', true), array(), null, array('class'=>'paging'));?>
		| <?php echo $this->Paginator->numbers();?> |
		<?php echo $this->Paginator->next(__('Tới', true) . ' >>', array(), null, array('class' => 'paging'));?>
	</div>
	
	<br />
	<div class="legend"> 
		<h6>Chú thích >></h6> 
		<div class="chars" style="padding-left: 10px;"> 
			<div>
				<span class="adtypeB"> </span>
				<img src="<?php echo $this->webroot; ?>img/post/types/1.gif" border="0" height="14" width="14">= Cần bán
			</div> 
			<div>
				<span class="adtypeM"> </span>
				<img src="<?php echo $this->webroot; ?>img/post/types/2.gif" border="0" height="14" width="14">= Cần mua
			</div> 
			<div style="">
				<span class="adtypeH"> </span>
				<img src="<?php echo $this->webroot; ?>img/post/types/3.gif" border="0" height="14" width="14">= Hợp tác - Cộng tác
			</div>
		</div>
		<div class="chars" style="padding-left: 10px;"> 
			<div>
				<span class="adtypeQ"> </span>
				<img src="<?php echo $this->webroot; ?>img/post/types/4.gif" border="0" height="14" width="14">= Quảng cáo
			</div> 
			<div>
				<span class="adtypeR"> </span>
				<img src="<?php echo $this->webroot; ?>img/post/types/5.gif" border="0" height="14" width="14">= Rao vặt
			</div> 
			<div>
				<span class="adtypeV"> </span>
				<img src="<?php echo $this->webroot; ?>img/post/types/6.gif" border="0" height="14" width="14">= Việc làm
			</div>
		</div>
	</div> 
</div>

<script>
function filter(){
	url = "<?php echo $this->webroot;?>posts/index/" + $('#ty_id').val() + "/" + $('#ca_id').val() + "/" + $('#ci_id').val() ;
	window.location = url;
}
</script>